<template>
  <div class="newsInfo-list">
    <h3 class="title">{{newsInfo.title}}</h3>
    <p class="subtime">
      <span>发表时间:{{newsInfo.add_time | dateFormat}}</span>
      <span>点击{{newsInfo.click}}次</span>
    </p>
    <hr />
    <div class="content" v-html="newsInfo.content"></div>
    <comment-box :id="this.id"></comment-box>
  </div>
</template>

<script>
// 导入commet组件
import comment from "../componentssub/commet";
export default {
  data() {
    return {
      id: this.$route.params.id,
      newsInfo: {} //新闻对象
    };
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
    getNewsInfo() {
      this.$http.get("api/getnew/" + this.id).then(result => {
        // console.log(result);

        this.newsInfo = result.data.message[0];
      });
    }
  },
  components: {
    "comment-box": comment
  }
};
</script>

<style lang="scss" scoped>
.newsInfo-list {
  padding: 0 5px;
}
.title {
  font-size: 18px;
  color: darkblue;
  margin: 15px 0;
  text-align: center;
}
.subtime {
  display: flex;
  justify-content: space-between;
  color: #22a;
}
.content {
  /deep/ img {
    width: 100%;
  }
}
</style>;
